package com.xyp.mesadmin.log.controller;

import com.github.pagehelper.PageInfo;
import com.xyp.mesadmin.log.param.LogPageParam;
import com.xyp.mesadmin.log.service.LogService;
import com.xyp.mescommon.common.PageParam;
import com.xyp.mescommon.common.R;
import com.xyp.mescommon.entity.log.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * --- 加油，努力 ---
 *
 * @Author XYP
 * @Date 2024/9/29
 * @Solgne 从想做到能做
 * @Desc
 */
@RestController
@RequestMapping("/log")
public class LogController {
    @Autowired
    private LogService logService;

    @GetMapping("/page")
    public R page (LogPageParam logPageParam) {
        System.out.println(logPageParam);
        PageInfo<Log> logs = logService.findAll(logPageParam);
        return R.ok(logs);
    }

    @GetMapping("/del")
    public R deleteById (Integer id) {
        logService.deleteById(id);
        return R.ok();
    }

    @GetMapping("/deleteBatch")
    public R deleteBatch (@RequestParam("ids") List<Integer> ids) {
        logService.deleteBatch(ids);
        return R.ok();
    }

    @GetMapping("/download/excel")
    public R exportExcel (HttpServletResponse response) {
        logService.exportExcel(response);
        return R.ok();
    }
}
